﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ChangeProblem.Logic
{
    public class ChangeProblemTwo
    {
        public int[] GetChangeTwo(decimal giveChange, decimal[] change, int[] moneyNumber)
        {
            int number = 0;
            for (int i = 0; i < change.Length; i++)
            {
                number = (int)(giveChange / change[i]);
                giveChange = giveChange % change[i];

                if(number > moneyNumber[i])
                {
                    giveChange = (number - moneyNumber[i]) * change[i];
                    moneyNumber[i] = 0;
                }
                else
                {
                    moneyNumber[i] = moneyNumber[i] - number;
                }

            }
            return moneyNumber;
        }

        public decimal CalculationChange(decimal commodityPrice, decimal payMent)
        {
            return payMent - commodityPrice;
        }
    }
}
